package com.hd123.rumba.gwt.widget.client.grid;

import com.google.gwt.user.client.ui.CheckBox;

public class CheckBoxEditor extends CheckBox implements CellEditor {

  public void activate(DxGrid grid, int row, int col, String text, String width, String height,
      boolean readOnly) {
    setValue(text);
    grid.setWidget(row, col, this);
    setWidth(width);
    setHeight(height);
    setStyleName("DxGrid-CellEditor");
    setFocus(true);
    setFocus(true);
  }

  public boolean isLeftKeyToLeave() {
    return true;
  }

  public boolean isRightKeyToLeave() {
    return true;
  }

  public void setValue(String value) {
    setChecked("true".equals(value));
  }

  public void setReadOnly(boolean readOnly) {
    setEnabled(!readOnly);
  }

}
